Skip to content

feat: Keploy schema-match sample app#99

Merged
Sarthak160 merged 6 commits into
mainfrom
python-schema-match
Feb 11, 2026
Merged

feat: Keploy schema-match sample app#99
Sarthak160 merged 6 commits into
mainfrom
python-schema-match

Conversation

@pathakharshit
Copy link
Copy Markdown
Contributor

@pathakharshit pathakharshit commented Feb 11, 2026

This pull request expands the test coverage and complexity of the schema matching application by introducing two new complex endpoints (/complex/user and /complex/product) and updating related test and check files. It also improves HTTP response handling by explicitly closing connections.

New complex endpoint support:

  • Added /complex/user and /complex/product endpoints with nested and array structures to app.py for more comprehensive schema testing.
  • Updated the endpoint list in check-endpoints.py to include the new complex endpoints, ensuring they are checked during validation.

Test coverage enhancements:

  • Added failing test cases for /complex/user and /complex/product in app-test.py, demonstrating schema mismatches such as type errors and missing keys.

HTTP response improvements:

  • Modified the HTTP response in handle_request to include Connection: close, ensuring proper socket closure after each request.

Signed-off-by: Harshit Pathak <harshit07pathak@gmail.com>
Signed-off-by: Harshit Pathak <harshit07pathak@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new Python sample application called "Python Schema Match" to demonstrate JSON schema validation capabilities with Keploy. The application is a socket-based HTTP server that provides multiple endpoints with various JSON response structures to test schema matching, including nested objects, arrays, edge cases, and data type validation.

Changes:

  • Added a socket-based HTTP server (app.py) with 12 endpoints serving different JSON response patterns
  • Added a test version of the server (app-test.py) with intentionally modified responses to demonstrate schema validation failures
  • Added an endpoint checker utility (check-endpoints.py) to test all endpoints automatically
  • Added comprehensive documentation (README.md) with setup instructions, API documentation, and Keploy integration guide

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
python-schema-match/app.py Original HTTP server implementation with 12 endpoints for recording test cases
python-schema-match/app-test.py Modified HTTP server with schema variations to test compatibility (5 intentional failures)
python-schema-match/check-endpoints.py Utility script to automatically test all 12 endpoints
python-schema-match/README.md Comprehensive documentation covering setup, usage, and expected test results
Comments suppressed due to low confidence (12)

python-schema-match/app.py:136

  • The socket.timeout exception is silently caught without any logging. This makes debugging timeout issues difficult. Consider adding at least a debug log message when timeouts occur, especially since client_socket.settimeout(5.0) is explicitly set. This would help diagnose connection issues during testing.
    except socket.timeout:
        pass

python-schema-match/check-endpoints.py:32

  • The unused variable 'body' is read from the response but never used. This could be removed to clean up the code unless it's intended for future functionality.
                body = response.read().decode('utf-8')

python-schema-match/app-test.py:8

  • According to the comment on line 6, the expected results are "PASS: 7" and "FAIL: 3". However, the RESPONSES dictionary contains 12 endpoints (endpoints 1-12 in comments), not 10. The comments indicate endpoints 4, 5, 6, 11, and 12 should fail (5 failures), but the documentation states only 3 failures. This inconsistency between the expected results comment and the actual test data needs to be resolved.
EXPECTED RESULTS (Total 10):
PASS: 7
FAIL: 3 (Missing Field, Type Mismatch, Hierarchy Mismatch)

python-schema-match/app.py:151

  • The error handling logic for port binding is flawed. If the port is already in use, the code waits 2 seconds and then attempts to bind again on the same port without verifying it's actually free. This will likely fail again with the same OSError. Consider either using a different port, implementing a retry loop with proper verification, or letting the error propagate to inform the user to free the port.
        server_socket.bind(('0.0.0.0', PORT))
    except OSError:
        print("Port in use, waiting...")
        time.sleep(2)
        server_socket.bind(('0.0.0.0', PORT))

python-schema-match/app.py:11

  • The 'sys' module is imported but never used in the code. Consider removing this unused import to clean up the code.
import sys

python-schema-match/check-endpoints.py:32

  • Variable body is not used.
                body = response.read().decode('utf-8')

python-schema-match/app-test.py:14

  • Import of 'time' is not used.
import time

python-schema-match/app.py:11

  • Import of 'sys' is not used.
import sys

python-schema-match/check-endpoints.py:3

  • Import of 'sys' is not used.
import sys

python-schema-match/app.py:135

  • 'except' clause does nothing but pass and there is no explanatory comment.
    except socket.timeout:

python-schema-match/app-test.py:162

  • Instance of context-manager class socket is closed in a finally block. Consider using 'with' statement.
        client_socket.close()

python-schema-match/app.py:140

  • Instance of context-manager class socket is closed in a finally block. Consider using 'with' statement.
        client_socket.close()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread python-schema-match/check-endpoints.py
Comment thread python-schema-match/app.py
@Sarthak160
Copy link
Copy Markdown
Contributor

@pathakharshit Please add readme which can be followed.

@Sarthak160 Sarthak160 changed the title Fully updated and few test-cases feat: Keploy schema-match sample app Feb 11, 2026
@pathakharshit pathakharshit changed the title feat: Keploy schema-match sample app Schema-Sample-App Feb 11, 2026
@Sarthak160 Sarthak160 changed the title Schema-Sample-App feat: Keploy schema-match sample app Feb 11, 2026
Copy link
Copy Markdown
Contributor

@Sarthak160 Sarthak160 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Sarthak160 Sarthak160 merged commit 57856de into main Feb 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants